import mqtt from "mqtt";

export const getMqttClient = () : mqtt.MqttClient => {
    const url = import.meta.env.VITE_MQTT_URL;
    console.log(options)
    const client = mqtt.connect(url, options);
    client.on('error', (error) => {
        console.log('连接失败:', error)
    })
    client.on('reconnect', () => {
        console.log('正在进行重连！');
    })
    return client;
}

const options: mqtt.IClientOptions = {
    keepalive: 60,
    clientId: 'test01',
    username: 'test01',
    password: '123456',
}